
<script type="text/javascript">
	$(function() {
		$("input[name=periodstart]").datepicker({
				showButtonPanel: true,
				changeMonth: true,
				changeYear: true,
				dateFormat: 'yy-mm-dd',
				minDate: new Date()
		});
		$("input[name=periodend]").datepicker({
				showButtonPanel: true,
				changeMonth: true,
				changeYear: true,
				dateFormat: 'yy-mm-dd',
				minDate: new Date()
		});
		$("input[name=deadline]").datepicker({
				showButtonPanel: true,
				changeMonth: true,
				changeYear: true,
				dateFormat: 'yy-mm-dd',
				minDate: new Date()
		});
	});

	function addrequiredfile() {
		var input = document.createElement("input");
		var br = document.createElement("br");
		input.setAttribute("type", "text");
		input.setAttribute("name", "addfiles[]");
		input.setAttribute("style", "width: 300px!important;"); 
		input.setAttribute("maxlength", "64");
		document.getElementById("requiredfile").appendChild(input);
		document.getElementById("requiredfile").appendChild(br);
	}
</script>

<div id="main-content" class="prepend-1 span-19 last">
	<h3>Tambah Beasiswa</h3>
<?php echo form_open($role.'/scholar/offer/add', array('class' => 'form', 'id' => 'addscholar', 'name' => 'addscholar')); ?>
	<table>
		<tr>
			<td width="200"><label>Nama Beasiswa</label></td>
			<td>
				<input style="width: 300px!important;" type="text" name="name" value="<?php echo set_value('name'); ?>" maxlength="64" />
				<?php echo form_error('name')?>
			</td>
		</tr>
		<tr>
			<td><label>Awal Periode</label></td>
			<td>
				<input name="periodstart" value="<?php echo set_value('periodstart'); ?>" size="12" readonly="readonly" />
				<?php echo form_error('periodstart'); ?>
			</td>
		</tr>
		<tr>
			<td><label>Akhir Periode</label></td>
			<td>
				<input name="periodend" value="<?php echo set_value('periodend'); ?>" size="12" readonly="readonly" />
				<?php echo form_error('periodend'); ?>
			</td>
		</tr>
		<tr>
			<td><label>Batas Pendaftaran</label></td>
			<td>
				<input name="deadline" value="<?php echo set_value('deadline'); ?>" size="12" readonly="readonly" />
				<?php echo form_error('deadline'); ?>
			</td>
		</tr>
		<tr>
			<td><label>Jenis Beasiswa</label></td>
			<td>
				<select name="type">
					<option value="" <?php echo set_select('type', '', TRUE); ?>>--Silakan pilih jenis beasiswa--</option>
<?php 
	foreach ($types as $type) {
		echo '<option value="'.$type.'" '.set_select('type', $type).'>'.$type.'</option>';
	}
?>
				</select>
				<?php echo form_error('type'); ?>
			</td>
		</tr>
		<tr>
			<td><label>Sponsor</label></td>
			<td>
				<select name="sponsor_id">
					<option value="" <?php echo set_select('sponsor_id', '', TRUE); ?>>--Silakan pilih sponsor--</option>
<?php 
	foreach ($sponsors as $sponsor) {
		echo '<option value="'.$sponsor->id.'" '.set_select('sponsor_id', $sponsor->id).'>'.$sponsor->name.'</option>';
	}
?>
				</select>
				<?php echo form_error('sponsor_id'); ?>
			</td>
		</tr>
		<tr>
			<td><label>Berkas Dibutuhkan</label></td>
			<td>
<?php 
	if ($files != NULL) :
	foreach ($files as $file) {
		echo '<input type="checkbox" name="requiredfiles[]" value="'.$file->id.'" '.set_checkbox('requiredfiles[]', $file->id).' /> '.$file->name.'<br />';
	}
	endif;
?>
				<div id="requiredfile">
<?php 
	if (isset($addfiles) && $addfiles != FALSE) {
		foreach ($addfiles as $addfile) {
			if ($addfile != "") {
				echo '<input maxlength="64" style="width: 300px!important;" type="text" name="addfiles[]" value="'.$addfile.'" /><br />';
			}
		}
	}
?>
				</div>
<?php echo $validatefiles; ?>
				<input type="button" onclick="addrequiredfile()" name="addfile" value="Tambah Berkas" id="addfile" class="submit" />
			</td>
		</tr>
		<tr>
			<td><label>Keterangan</label></td>
			<td>
				<textarea cols="" rows="" name="details" class="textmini"><?php echo set_value('details'); ?></textarea>
				<?php echo form_error('details'); ?>
			</td>
		</tr>
	</table>
	<input type="submit" value="Tambah Beasiswa" name="add" class="submit" />
<?php echo form_close(); ?>
	<div class="clear"><?php echo nbs(); ?></div>
</div>
